<script>
function get_report(from_date,to_date,type,id_product, id_customer, id_supplier){
	
	if((id_customer !== '0') && (id_supplier !== '0')){
		alert('Invalid request!!')
	}else{
		if(from_date !='' && to_date !=''){
				
						$.post("<?= site_url('report/daily_report/prepare_report')?>",{ from_date: from_date, to_date:to_date, type:type, id_product:id_product,id_customer:id_customer, id_supplier:id_supplier }, function(msg){
							if(msg){
								$("#report").show();
								$("#report").html(msg);	
							}
		
						})
		
	}else{
		
		alert("Select The Date!!")
		return false
	}

	}
		

}

</script>
<h2 style="background-color:#368EE0; color:white; font-size:20px; padding:5px;">Report</h2>
<div class="row-fluid">
<div class="span2">&nbsp;&nbsp;&nbsp;</div>
<div class="span8">
<table width="100%" >
<tr>
<td><b>From Date: </b></td>
<td><b>To  Date: </b></td>
<td><b>Select Report Type:</b></td>

</tr>
<tr> 
<td><br><?php echo form_input($from_date);?></td>
<td><br><?php echo form_input($to_date);?></td>
<td>
		<select id="type"  class="chzn-select" >
		<option value="sale">Sales</option>
		<option value="purchase">purchase</option>
		<option value="stock">Stock</option>	
		</select>
</td>
</tr>
<tr>
<td><b>Product: </b></td>
<td><b>Select Customers: </b></td>
<td><b>Select Suppliers: </b></td>
</tr>
<tr> 
 <td>   <?php 
	 	$b1[0] = "--Select Product Code--";
		$b1['all'] = "All";
	   		foreach($products as $product){
				$b1[$product->id] = $product->code;
			}
			echo form_dropdown('id_product', $b1, '', 'class="chzn-select" id="id_product" data-placeholder="Choose a Product Code" style="width:220px;"');  ?>
	</td>
 <td>   <?php 
	 	$b2[0] = "--Select Customer--";
		$b2['all'] = "All";
	   		foreach($customers as $customer){
				$b2[$customer->id] = $customer->name;
			}
			echo form_dropdown('id_customer', $b2, '', 'class="chzn-select" id="id_customer" data-placeholder="Choose a Product Code" style="width:220px;"');  ?>
	</td>
 <td>   <?php 
	 	$b3[0] = "--Select Supplier--";
		$b3['all'] = "All";
	   		foreach($suppliers as $supplier){
				$b3[$supplier->id] = $supplier->name;
			}
			echo form_dropdown('id_supplier', $b3, '', 'class="chzn-select" id="id_supplier" data-placeholder="Choose a Product Code" style="width:220px;"');  ?>
	</td>
</tr>

<tr><td>&nbsp;</td><tr>
<tr><td>&nbsp;</td><td>&nbsp;</td>
	<td><p align="right"><input type="button" onclick="get_report($('#from_date').val(),$('#to_date').val(),$('#type').val(),$('#id_product').val(),$('#id_customer').val(),$('#id_supplier').val());"   value="Get Report" class="btn btn-inverse"></p></td>
    </tr>
	</table>
	</div>
	<div class="span2">&nbsp;&nbsp;&nbsp;</div>
</div>	
<div class="line"></div>
<div class="row-fluid">
<div class="span12" id="report" style="display: none">
lkhkjthkjtrhekj
</div>	
	